// 数组去重
const arr = [1, 2, 2, 4, 6, 4]
const unique1 = arr => {
  const result = []

  arr.forEach(item => {
    if (!result.includes(item)) {
      result.push(item)
    }
  })

  return result
}

const unique2 = arr => {
  const result = []
  const contain = {}

  arr.forEach(item => {
    if (!contain.hasOwnProperty(item)) {
      result.push(item)
      contain[item] = true
    }
  })

  return result
}

const unique3 = arr => [...new Set(arr)]

const unique4 = arr => Array.from(new Set(arr))

const unique5 = arr => arr.filter((item, i) => arr.indexOf(item) === i)

console.log(unique5(arr))
